<template>
	<view>
		
		<u-table style="margin-top: 10rpx;">
			<u-tr class="u-tr">
				<u-th class="u-th">起始位置</u-th>
				<u-th class="u-th">终点位置</u-th>
				<u-th class="u-th">优先级</u-th>
				<u-th class="u-th">下发人</u-th>
				<!-- <u-th class="u-th">任务取消</u-th> -->
			</u-tr>
			<u-tr class="u-tr" v-for="(item,index) in dataList" :key="index" >
				<u-td class="u-td">{{item.srcPositionCode }}</u-td>
				<u-td class="u-td" ><text :style="{ color: item.overFlag }">{{item.tarPositionCode}}</text></u-td>
				<u-td class="u-td"><text style="color: blue;" @click="zhijian(item)">{{item.priority}}</text></u-td>
				<u-td class="u-td">{{item.createUserName}}</u-td>
				<!-- <u-td class="u-td"><text style="color: red;" @click="quxiao(item)">取消</text></u-td> -->
			</u-tr>
		</u-table>
		<u-popup v-model="show" mode="center" width="500rpx" height="400rpx" border-radius="10">
			<view class="u-text-center u-m-t-20">优先级</view>
			<view class=" u-m-20">
				<u-input v-model="TaskGenAgvHkParam.priority" type="digit" :border="true"
					placeholder="请输入优先级" />
			</view>
			<view style="height: 80rpx;text-align: center;">
				<view class="close-btn u-m-t-40">
					<u-button size="medium" @click="define()">确定</u-button>
				</view>
			</view>
		</u-popup>

		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>
<script>

	export default {

		data() {
			return {
					show: false,
					keyword:'',
					TaskGenAgvHkParam:{},
					dataList:[],
					srcPositionCode: "", //开始库位
					tarPositionCode: "", //目标位置
					/* taskNo:"",//任务号 */
					priority:"",//优先级
			}
		},
		
		onShow() {
			this.refresh()
		},
		onPullDownRefresh() {
			this.refresh()
			uni.stopPullDownRefresh()
		},
		
		methods: {

			define() {
				this.$http.post('/rest/hikAgvTaskController/setPriorityJL', {}, {
					params: {
						id: this.TaskGenAgvHkParam.id,
						priority: this.TaskGenAgvHkParam.priority,
						taskNo: this.TaskGenAgvHkParam.taskNo,
					},
					header: {
						'Authorization': uni.getStorageSync('token'),
					}
				}).then(res => {
					if (res.statusCode == 200) {
						if(res.data.code == 200){
							this.$refs.uToast.show({
								title: '操作成功',
								duration: 3000,
								type: 'success'
							})
							this.refresh();
						}else{
							this.$refs.uToast.show({
								title: res.data.message,
								duration: 3000,
								type: 'error'
							})
						}
					} else {
						this.$refs.uToast.show({
							title: res.data.message,
							type: 'error'
						})
					}
				})
				this.show = false
			},
			
			refresh() {
					this.$http.post('/rest/hikAgvTaskController/listJL', {}, {
						params: {
							tarPositionCode: this.keyword,
						},
						header: {
							'Authorization': uni.getStorageSync('token'),
						}
					}).then(res => {
						console.log(res)
						uni.hideLoading()
						if (res.statusCode == 200) {
							this.dataList = res.data
							this.keyword = ""
						} else {
							this.$refs.uToast.show({
								title: res.data.message,
								type: 'error'
							})
							setTimeout(() => {
								this.$Router.back()
							}, 1500)
						}
					})
			},
			
			zhijian(item) {
				this.show = true
				this.TaskGenAgvHkParam.id = item.id;
				this.TaskGenAgvHkParam.taskNo = item.taskNo;
				this.TaskGenAgvHkParam.priority = item.priority;
			},
			// quxiao(item) {
			// 	uni.showModal({
			// 		title:'确认要取消吗?',
			// 		success: (res) => {
			// 			if (res.confirm) {
			// 				//清空通道
			// 				this.$http.post('/rest/hikAgvTaskController/cancelTask', {}, {
			// 					params: {
			// 						taskCode: item.taskNo
			// 					},
			// 					header: {
			// 						'Authorization': uni.getStorageSync('token'),
			// 					}
			// 				}).then(res => {
			// 					if (res.statusCode == 200) {
			// 						if(res.data.code == 200){
			// 							this.$refs.uToast.show({
			// 								title: '操作成功',
			// 								duration: 3000,
			// 								type: 'success'
			// 							})
			// 							this.refresh();
			// 						}else{
			// 							this.$refs.uToast.show({
			// 								title: res.data.message,
			// 								duration: 3000,
			// 								type: 'error'
			// 							})
			// 						}
			// 					} else {
			// 						this.$refs.uToast.show({
			// 							title: res.data.message,
			// 							duration: 3000,
			// 							type: 'error'
			// 						})
			// 					}
			// 				})
			// 			} else if (res.cancel) {
			// 				console.log('用户点击取消');
			// 			}
			// 		}
			// 	})
			// }
		}
	}
</script>
<style lang="scss">
	page {
		background-color: #ffffff;
	}
	
	.wrap {
		padding: 30rpx;
	}
</style>